#include <stdio.h>
#include <stdlib.h>

typedef int DataType;
struct SeqStackNode
{
    int MAX;         
    int top;        
    DataType *elem; 
};
typedef struct SeqStackNode *SeqStack;

SeqStack SetNullStack_Seq(int m) 
{
    SeqStack sstack = (SeqStack)malloc(sizeof(struct SeqStackNode));
    if (sstack != NULL) {
        sstack->elem = (DataType*)malloc(sizeof(DataType)*m);
        if (sstack->elem != NULL) {
            sstack->MAX = m;
            sstack->top = -1;
            return(sstack);
        }
        else {
            free(sstack);
            return NULL;
        }
    }
    else {
        printf("out of space");
        return NULL;
    }
}

int IsNullStack_seq(SeqStack sstack) 
{
    return(sstack->top == -1);
}
void Push_seq(SeqStack sstack, int x)  
{
    if(sstack->top >= sstack->MAX -1){
        printf("overflow!\n");
        return;
    }
    sstack->top++;
    sstack->elem[sstack->top] = x;
}
void Hexconversion(SeqStack sstack, int n) 
{
    while(n){
        int tmp = n % 16;
        Push_seq(sstack, tmp);
        n /= 16;
    }
    while(!IsNullStack_seq(sstack)){
        int now = Top_seq(sstack);
        Pop_seq(sstack);
        char letter[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
        printf("%c", letter[now]);
    }
}
void Pop_seq(SeqStack sstack)
{
    if (IsNullStack_seq(sstack)) 
        printf("Underflow!\n");
    else
        sstack->top = sstack->top - 1;
}
DataType Top_seq(SeqStack sstack)
{
    if (IsNullStack_seq(sstack))
    {
        printf("it is empty");
        return 0;
    }
    else
        return sstack->elem[sstack->top];
}
int main()
{
    SeqStack mystack = NULL;
    int n;
    mystack = SetNullStack_Seq(4);
    scanf("%d", &n);
    Hexconversion(mystack, n);
    return 0;
}